package lottery;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.Session;

import dao.HibernateSessionFactory;

/**
 * Betway管理
 * @author liuding,2012-5-8
 *
 * $LastChangedDate$
 * $Author$ 
 */
@Entity
@Table
public class BetwayManage
{
    private int id;
    private int lotteryId;
    private String lotteryName;
    private int betwayId;
    private String betwayName;
    private int status; //1-off|0-on
    private double returnPoint; //返点基数
    private double reward; //奖金基数
    private double maxFrontReturnPoint; //前台开户最高返点
    private double topReturnDistance; //上下级返点差
    private int isAdjustable; //是否可以调节，默认可以调节1-不可调节|0-可调节
    
    public int getBetwayId()
    {
        return betwayId;
    }
    public void setBetwayId(int betwayId)
    {
        this.betwayId = betwayId;
    }
    @Column(length=30)
    public String getBetwayName()
    {
        return betwayName;
    }
    public void setBetwayName(String betwayName)
    {
        this.betwayName = betwayName;
    }
    @Id
    @GeneratedValue
    public int getId()
    {
        return id;
    }
    public void setId(int id)
    {
        this.id = id;
    }
    public int getLotteryId()
    {
        return lotteryId;
    }
    public void setLotteryId(int lotteryId)
    {
        this.lotteryId = lotteryId;
    }
    @Column(length=30)
    public String getLotteryName()
    {
        return lotteryName;
    }
    public void setLotteryName(String lotteryName)
    {
        this.lotteryName = lotteryName;
    }
    public double getReturnPoint()
    {
        return returnPoint;
    }
    public void setReturnPoint(double returnPoint)
    {
        this.returnPoint = returnPoint;
    }
    public double getReward()
    {
        return reward;
    }
    public void setReward(double reward)
    {
        this.reward = reward;
    }
    public int getStatus()
    {
        return status;
    }
    public void setStatus(int status)
    {
        this.status = status;
    }
    
    
    public double getMaxFrontReturnPoint() {
		return maxFrontReturnPoint;
	}
	public void setMaxFrontReturnPoint(double maxFrontReturnPoint) {
		this.maxFrontReturnPoint = maxFrontReturnPoint;
	}
	public double getTopReturnDistance() {
		return topReturnDistance;
	}
	public void setTopReturnDistance(double topReturnDistance) {
		this.topReturnDistance = topReturnDistance;
	}
	public int getIsAdjustable() {
		return isAdjustable;
	}
	public void setIsAdjustable(int isAdjustable) {
		this.isAdjustable = isAdjustable;
	}
	
	public static void main(String[] args)
    {
        Session s = HibernateSessionFactory.getSession();
        s.beginTransaction();
        List<Lottery> lotteries = s.createQuery("from Lottery").list();
        List<BetWay> betways = s.createQuery("from BetWay").list();
        s.getTransaction().commit();
        s.beginTransaction();
        for(int i=0; i<lotteries.size(); i++){
            Lottery lt = lotteries.get(i);
            if(!lt.getName().contains("时时彩"))
                continue;
            for(int j=0; j<betways.size(); j++){
                BetWay way = betways.get(j);
                BetwayManage bm = new BetwayManage();
                bm.setBetwayId(way.getId());
                bm.setBetwayName(way.getName());
                bm.setLotteryId(lt.getId());
                bm.setLotteryName(lt.getName());
                bm.setReturnPoint(18.5);
                bm.setReward(1600);
                bm.setStatus(0);
                s.save(bm);
            }
        }
        s.getTransaction().commit();
        s.close();
    }
    
}
